#ifndef QS60TELEPHONY_H
#define QS60TELEPHONY_H

// INCLUDES
#include <QObject>
#include "telephony_global.h"

// FORWARD DECLARATIONS
class QS60TelephonyPrivate;

// CLASS DECLARATION
class QS60Telephony : public QObject
{
    Q_OBJECT
    Q_DECLARE_PRIVATE(QS60Telephony)
    Q_ENUMS(LineStatus)
    Q_ENUMS(Error)
    Q_CLASSINFO("Author", "Sebastiano Galazzo")
    Q_CLASSINFO("Email", "sebastiano.galazzo@gmail.com")

public:
    enum Error {
        NoError = 0,
        OutOfMemoryError,
        AccessDeniedError,
        TimedOutError,
        UnknownError = -1
    };
    
    enum LineStatus {
        StatusUnknown,
        StatusIdle,
        StatusDialling,
        StatusRinging,
        StatusAnswering,
        StatusConnecting,
        StatusConnected,
        StatusReconnectPending,
        StatusDisconnecting,
        StatusHold,
        StatusTransferring,
        StatusTransferAlerting
    };
    
    explicit QS60Telephony(QObject* parent = 0);
    ~QS60Telephony();
    
    /**
     * @brief Read the IMEI Code
     */
    Q_INVOKABLE QString IMEI();

    Q_INVOKABLE QS60Telephony::Error error() const;

public slots:
    /**
     * @brief Make a phone call
     * @param phone number
     */
    void call(const QString& phoneNumber);    

    /**
     * @brief Answer incoming call
     */
    void answerIncomingCall();

    /**
     * @brief Terminate a call
     */
    void terminateCall();

    /**
     * @brief Reject a call
     */
    void rejectCall();
#ifdef RECENT_CALLS
    void recentCalls();
#endif
    bool startMonitoringLine();
    void toBackground();
    void stopMonitoringLine();    
    void showOnTop();
    void showNormal();
    
private slots:
    void showOnTopDelayed();

signals:
    void lineStatusChanged(QS60Telephony::LineStatus status, QString number);
    void error(QS60Telephony::Error error);
    void answered();
    void terminated();
    
private:
    LineStatus cStatus;

private:
    friend class QS60TelephonyPrivate;
    QS60TelephonyPrivate* d;
};

#endif // QS60TELEPHONY_H

// End of file
